package com.woniuxy.movice.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.One;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.woniuxy.movice.dto.User;

public interface UserMapper {

	@Select("select * from users where account=#{account}")
	@Results({ @Result(id = true, column = "uid", property = "uid"), @Result(column = "account", property = "account"),
		@Result(column = "pass", property = "pass"), @Result(column = "vid", property = "vid"),
		@Result(column = "ucast", property = "ucast"), @Result(column = "zid", property = "zid"),
		@Result(column = "ustate", property = "ustate"),@Result(column = "uname", property = "uname"),
		@Result(column = "sex", property = "sex"), @Result(column = "birth", property = "birth"),
		@Result(column = "message", property = "message"),
		@Result(column = "vid", property = "vip", one = @One(select = "com.woniuxy.movice.mapper.VipMapper.findVipByVid"))})
	User findUserInfoByAccount(String account);
	//根据用户名密码查找用户
	@Select("SELECT *FROM users WHERE account=#{account} AND pass=#{pass}")
	public User userLogin(String account,String pass);
	//用户注册添加
	@Insert("INSERT INTO users (account,pass,tel) VALUES (#{account},#{pass},#{tel})")
	public void userRegister(User user);
	@Select("SELECT *FROM users WHERE account=#{account}")
	public User accountByUser(String account);
	

	@Update("update users set uname=#{uname},sex=#{sex},birth=#{birth},userState=#{userState},userJob=#{userJob},message=#{message} where account=#{account}")
	int updateUser(User user);

}
